@args(){
    AdminsRulesModel adminsRule
    List<AdminsRulesSourcesModel> adminsRulesSources
}
<!DOCTYPE HTML>
<html>
    <head>
		<meta charset="utf-8">
		<title>权限用户</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		
		<!--[if lt IE 9]>
		<script type="text/javascript" src="@__ASSET__/admin/lib/html5shiv.js"></script>
		<script type="text/javascript" src="@__ASSET__/admin/lib/respond.min.js"></script>
		<![endif]-->
		
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/static/h-ui.admin/css/style.css" />   
		<link rel="stylesheet" type="text/css" href="@__ASSET__/admin/css/main.css" />           
		
		<!--[if IE 6]>
		<script type="text/javascript" src="@__ASSET__/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
		<script>DD_belatedPNG.fix('*');</script>
		<![endif]-->      	
		
		<!-- ztree插件 -->
		<link rel="stylesheet" href="@__ASSET__/admin/js/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<style type="text/css">
		    #form1 .ztree li span{line-height:15px;}
		    #form1 .set-tree{display: none;}
		</style>	
	</head>
    <body>      
        <!-- 面包屑 -->
        <nav class="breadcrumb">
            <i class="Hui-iconfont"></i>
			首页 <span class="c-gray en">&gt;</span>
			权限管理<span class="c-gray en">&gt;</span>
			<a href='@fullUrl({value="AdminsRules.index"})'>权限角色</a><span class="c-gray en">&gt;</span>
			修改或添加权限角色 <a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
        </nav>      
        <div class="page-container">
        	<!-- 如果有id说明是在修改啊 -->
        	@if(adminsRule.getRuleid()){
            	<form class="form form-horizontal" id="form1" action='@fullUrl({value="AdminsRules.editHandler"})' method="post">
            }else{
            	<form class="form form-horizontal" id="form1" action='@fullUrl({value="AdminsRules.addHandler"})' method="post">
            }                
		        <div class="row cl">
		            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色名称：</label>
		            <div class="formControls col-xs-8 col-sm-9">
		                <input type="text" class="input-text" value="@adminsRule.getRulename()" placeholder="" id="rulename" name="adminsRulesData.rulename">
		            </div>
		        </div>
		        <div class="row cl">
		            <label class="form-label col-xs-4 col-sm-3">权限资源：</label>
		            <div class="formControls col-xs-8 col-sm-9 ztree">
                        <!-- 树结构基本设置开始 -->
			            <ul id="treeDemo" class="ztree"></ul> 
			            <input type="hidden" name="adminsRulesData.sourceids" value="@adminsRule.getSourceids()"/>
			            <div class="set-tree">     
			                <input type="checkbox" id="py" class="checkbox first" checked />
			                <input type="checkbox" id="sy" class="checkbox first" checked />
			                <input type="checkbox" id="pn" class="checkbox first" />
			                <input type="checkbox" id="sn" class="checkbox first" checked />
			                <ul id="code" class="log" style="height:20px;"></ul>   
			            </div>  
			            <!-- 树结构基本设置结束 -->
		            </div>
		        </div>
		        		        
		        <div class="row cl">
		            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
		            	<!-- 如果有id说明是在修改啊 -->
		            	@if(adminsRule.getRuleid()){
		            		<input type="hidden" value="@adminsRule.getRuleid()" name="adminsRulesData.ruleid" id="ruleid"/>
		            	}
		            	<div class="set-tree"></div>
		                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		            </div>
		        </div>
		    </form>
        </div>    
            
        <script type="text/javascript" src="@__ASSET__/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
        <script type="text/javascript" src="@__ASSET__/admin/static/h-ui/js/H-ui.min.js"></script>
         
        <!--_footer 作为公共模版分离出去-->
        <script type="text/javascript" src="@__ASSET__/admin/lib/layer/2.4/layer.js"></script> 
        <script type="text/javascript" src="@__ASSET__/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
        <!--/_footer 作为公共模版分离出去-->
        
        <!--请在下方写此页面业务相关的脚本-->
        <script type="text/javascript" src="@__ASSET__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
           
        <!-- 权限资源列表插件 -->
        <script type="text/javascript" src="@__ASSET__/admin/js/ztree/js/jquery.ztree.core-3.5.js"></script>
        <script type="text/javascript" src="@__ASSET__/admin/js/ztree/js/jquery.ztree.excheck-3.5.js"></script>
        <script type="text/javascript" src="@__ASSET__/admin/js/ztree/js/jquery.ztree.exedit-3.5.js"></script>
        <script type="text/javascript">
            var setting = {
                check: {
                    enable: true
                },
                data: {
                    simpleData: {
                        enable: true,
                    }           
                },
                callback:{
                    onCheck:onCheck
                }
            };
            
            function onCheck(e,treeId,treeNode){
                var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),
                nodes=treeObj.getCheckedNodes(true),
                v="";
                for(var i=0;i<nodes.length;i++){
                	if(i < nodes.length-1){
                	    v+=nodes[i].id + ","; 
                	}else{
                		v+=nodes[i].id;
                	}
                }
                $('input[name="adminsRulesData.sourceids"]').val(v);
            }
                  
            //数据库中的值
            var oldsourceids = "@adminsRule.getSourceids()".split(',');
            
            //检测当前的值是否已经选中，如果选中就返回true
            function check_checked(sourceid){
            	var reg = new RegExp("(^"+sourceid+",)|(^"+sourceid+"$)|(,"+sourceid+",)|(,"+sourceid+"$)");            	
            	if(reg.test(oldsourceids.toString())){
            		return true;
            	}else{
            		return false;
            	}
            }
            
            //通过java for来输出当前的列表
            var zNodes =[
                @for(AdminsRulesSourcesModel source:adminsRulesSources){
                	{ id:@source.getSourceid(),pId:@source.getPsourceid(), name:'@source.getSourcename()',checked:check_checked("@source.getSourceid()"),open:true},
                }
            ];
            
            var code;
            
            function setCheck() {
                var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
                py = $("#py").attr("checked")? "p":"",
                sy = $("#sy").attr("checked")? "s":"",
                pn = $("#pn").attr("checked")? "p":"",
                sn = $("#sn").attr("checked")? "s":"",
                type = { "Y":py + sy, "N":pn + sn};
                zTree.setting.check.chkboxType = type;
                showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
            }
            function showCode(str) {
                if (!code) code = $("#code");
                code.empty();
                code.append("<li>"+str+"</li>");
            }
            
            $(document).ready(function(){
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                setCheck();
                $("#py").bind("change", setCheck);
                $("#sy").bind("change", setCheck);
                $("#pn").bind("change", setCheck);
                $("#sn").bind("change", setCheck);
            });
        </script>
        
        <!-- ajaxsubmit提交插件啦 -->
        <script type="text/javascript" src="@__ASSET__/admin/lib/jquery.form.min.js"></script>
        <script type="text/javascript">
	        $(function () {
	            var options = {
	                success: function (data) {
	                    if(data.errcode == 0){	                    	
	                    	layer.msg(data.msg,{icon:3});
	                    	setTimeout(function(){
	                    		window.location.href='@fullUrl({value="AdminsRules.index"})';
	                    	},1000);
	                    	return true;
	                    }else{
	                    	layer.msg(data.msg,{icon:3});
	                    	return false;
	                    }
	                }
	            };
	            $("#form1").ajaxForm(options);
	        });
        </script>
    </body>
</html>